<?php
header('Content-Type: application/json; charset=utf-8');
include_once("./include/conn.php");
$conn=mysqli_connect(HOST,MUSERNAME,MPASSWORD,DB);
// 检查连接
if ($conn->connect_error) {
    die(json_encode(["error" => "连接失败: " . $conn->connect_error]));
}
// 设置字符集
$conn->set_charset("utf8");
$pagesize = 50;
$page = 0;
$sql = "select * from employees  order by emp_no limit ". $page . "," . $pagesize .";" ;
$result = mysqli_query($conn,$sql);

$count = 0;
$json_data = array();
$data = array();
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $data[] =  $row;
        $count++;
    }
}
// else {
//     $data = ["message" => "0 结果"];
// }
//输出layui接受的json格式数据
$json_data["code"] = 0;
$json_data["msg"] = '雇员详情';
$json_data["count"] = $count;
$json_data["data"] = $data;

echo json_encode($json_data,JSON_UNESCAPED_UNICODE);

mysqli_close( $conn );
?>